www.gusucode.com > 用matlab gui 实现界面互相切换功能 给你带来新的方法 创建不同类型的界面源码程序 > 用matlab gui 实现界面互相切换功能 给你带来新的方法 创建不同类型的界面源码程序/hit_tab.m
function hit_tab(action) % HIT_TAB - callback function to activate the tab switching % switch action case 'start' set(gcbf,'WindowButtonMotionFcn','') set(gcbf,'WindowButtonUpFcn','hit_tab(''stop'')') case 'stop' tab = get(gco,'UserData'); % returns the handle of the tab all_child = get(tab,'UserData'); % gets all the children of % that tab tab_child = all_child.tab; inp_child = all_child.inp; matrix_child = all_child.matrix; ax_handle = get(gca,'Children'); % turn off the input fields for the current tab cur_tab = get(gca,'Userdata'); % current tab cur_chl = get(cur_tab,'Userdata'); % children of the current tab set(cur_chl.inp,'Visible','off') set(cur_chl.matrix,'Visible','off') set(inp_child,'Visible','on') set(matrix_child,'Visible','on') % changing the tab for i = 1:3 idx(i) = find(tab_child(i)==ax_handle); end ax_handle(idx) = ax_handle(1:3); ax_handle(1:3) = tab_child; set(gca,'Children',ax_handle) set(gca,'Userdata',tab) end